/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * tambahDaftarTayang.java
 *
 * Created on Dec 3, 2011, 11:58:02 AM
 */
package com.tiketBioskop.gui;

import com.tiketBioskop.entity.daftarTayang;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author sepha
 */
public class tambahDaftarTayang extends java.awt.Dialog {

    daftarTayang daf = new daftarTayang();
    List<daftarTayang> listdaftar = new ArrayList<daftarTayang>();

    /** konstruktor */
    public tambahDaftarTayang(java.awt.Frame parent, boolean modal) throws SQLException {
        super(parent, modal);
        initComponents();
        this.setLocationRelativeTo(null);
        this.tampilTabel();
        tabelDaftarFilm.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                int row = tabelDaftarFilm.getSelectedRow();
                if (row != -1) {
                    ubahDaftarTayang();
                }
            }
        });
    }

    public void tampilTabel() throws SQLException {
        listdaftar = daf.viewdaftarTayang();
        Object data[][] = new Object[listdaftar.size()][6];
        int x = 0;
        for (daftarTayang g : listdaftar) {
            data[x][0] = g.getIDFilm();
            data[x][1] = g.getNamaFilm();
            data[x][2] = g.getHari();
            data[x][3] = g.getJamTayang();
            data[x][4] = g.getHargaTiket();
            data[x][5] = g.getStudio();
            x++;
        }
        String judul[] = {"Id FIlm ", "Nama Film", "Hari", "Jam Tayang", "Harga Tiket", "Studio"};
        tabelDaftarFilm.setModel(new DefaultTableModel(data, judul));
        jScrollPane1.setViewportView(tabelDaftarFilm);
    }

    public void ubahDaftarTayang() {
        daftarTayang da = listdaftar.get(tabelDaftarFilm.getSelectedRow());
        txtId.setText(String.valueOf(da.getIDFilm()));
        txtNamaFilm.setText(da.getNamaFilm());
        if (da.getHari().equals("Senin")) {
            comboHari.setSelectedIndex(0);
        } else if (da.getHari().equals("Selasa")) {
            comboHari.setSelectedIndex(1);
        } else if (da.getHari().equals("Rabu")) {
            comboHari.setSelectedIndex(2);
        } else if (da.getHari().equals("Kamis")) {
            comboHari.setSelectedIndex(3);
        } else if (da.getHari().equals("Jumat")) {
            comboHari.setSelectedIndex(4);
        } else if (da.getHari().equals("Sabtu")) {
            comboHari.setSelectedIndex(5);
        } else {
            comboHari.setSelectedIndex(6);
        }
        if (da.getJamTayang().equals("09:00 - 12:00")) {
            comboJamTayang.setSelectedIndex(0);
        } else if (da.getJamTayang().equals("12:30 - 14:30")) {
            comboJamTayang.setSelectedIndex(1);
        } else if (da.getJamTayang().equals("15:00 - 17:00")) {
            comboJamTayang.setSelectedIndex(2);
        } else if (da.getJamTayang().equals("17:30 - 19:30")) {
            comboJamTayang.setSelectedIndex(3);
        } else {
            comboJamTayang.setSelectedIndex(4);
        }
        txtHargaTiket.setText(String.valueOf(da.getHargaTiket()));
        if (da.getStudio().equals("Studio A")) {
            comboStudio.setSelectedIndex(0);
        } else if (da.getStudio().equals("Studio B")) {
            comboStudio.setSelectedIndex(1);
        } else if (da.getStudio().equals("Studio C")) {
            comboStudio.setSelectedIndex(2);
        } else {
            comboStudio.setSelectedIndex(3);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtId = new javax.swing.JTextField();
        txtNamaFilm = new javax.swing.JTextField();
        comboHari = new javax.swing.JComboBox();
        comboJamTayang = new javax.swing.JComboBox();
        txtHargaTiket = new javax.swing.JTextField();
        comboStudio = new javax.swing.JComboBox();
        btnTambah = new javax.swing.JButton();
        btnUbah = new javax.swing.JButton();
        btnHapus = new javax.swing.JButton();
        btnBatal = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelDaftarFilm = new javax.swing.JTable();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel1.setFont(new java.awt.Font("Kristen ITC", 1, 14));
        jLabel1.setText("Halaman Tambah Daftar Film");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(76, 76, 76)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(257, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel2.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel2.setText("ID Film");

        jLabel3.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel3.setText("Nama Film");

        jLabel4.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel4.setText("Jam Tayang");

        jLabel5.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel5.setText("Hari");

        jLabel6.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel6.setText("Harga Tiket");

        jLabel7.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        jLabel7.setText("Studio");

        comboHari.setFont(new java.awt.Font("Kristen ITC", 0, 10));
        comboHari.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu" }));

        comboJamTayang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "09:00 - 12:00", "12:30 - 14:30", "15:00 - 17:00", "17:30 - 19:30", "20:00 - 22:00" }));

        comboStudio.setFont(new java.awt.Font("Kristen ITC", 0, 10)); // NOI18N
        comboStudio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Studio A", "Studio B", "Studio C", "Studio D" }));

        btnTambah.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        btnTambah.setText("Tambah");
        btnTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTambahActionPerformed(evt);
            }
        });

        btnUbah.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        btnUbah.setText("Ubah");
        btnUbah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUbahActionPerformed(evt);
            }
        });

        btnHapus.setFont(new java.awt.Font("Kristen ITC", 1, 10)); // NOI18N
        btnHapus.setText("Hapus\n");
        btnHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHapusActionPerformed(evt);
            }
        });

        btnBatal.setFont(new java.awt.Font("Kristen ITC", 1, 10));
        btnBatal.setText("Batal\n");
        btnBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBatalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnTambah)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(comboJamTayang, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(comboHari, javax.swing.GroupLayout.Alignment.LEADING, 0, 108, Short.MAX_VALUE)
                                .addComponent(comboStudio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtHargaTiket, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNamaFilm, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtId, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(btnUbah)
                        .addGap(10, 10, 10)
                        .addComponent(btnHapus)
                        .addGap(18, 18, 18)
                        .addComponent(btnBatal)))
                .addContainerGap(235, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtNamaFilm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(comboHari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(comboJamTayang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtHargaTiket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboStudio, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(20, 20, 20)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnTambah)
                    .addComponent(btnUbah)
                    .addComponent(btnBatal)
                    .addComponent(btnHapus))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        tabelDaftarFilm.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6"
            }
        ));
        jScrollPane1.setViewportView(tabelDaftarFilm);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 569, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addGap(1, 1, 1)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 95, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //untuk menutup dialogx 
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog

    private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTambahActionPerformed
        if (txtId.getText().isEmpty() || txtNamaFilm.getText().isEmpty() || txtHargaTiket.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Data Tidak Boleh Kosong"); //joption untuk menmpilkan dialog, this agar dapat ditampilkan di frame tersebut

        } else {
            try {
                daf.setIDFilm(Integer.parseInt(txtId.getText())); //setiap tipe data set yg bertipe int harus menggunakan integerparseint, integervalue untk mengambil data yg bertipe DATE
                daf.setNamaFilm(txtNamaFilm.getText());
                daf.setHari(comboHari.getSelectedItem().toString()); //selecteditem yg bertipe data Object  ditambahkan tipe data apasaja makan menjadi tipe data tsb
                daf.setJamTayang(comboJamTayang.getSelectedItem().toString());
                daf.setHargaTiket(Integer.parseInt(txtHargaTiket.getText()));
                daf.setStudio(comboStudio.getSelectedItem().toString());
                daf.tambahDaftarTayang();
                JOptionPane.showMessageDialog(this, "Data Berhasil Ditambahkan"); //joption untuk menmpilkan dialog, this agar dapat ditampilkan di frame tersebut
                txtId.setText(null); //untuk mengosongkan txt jika data sudah disimpan
                txtNamaFilm.setText(null);
                comboHari.setSelectedItem("Senin");
                comboJamTayang.setSelectedItem("09:00 - 12:00");
                txtHargaTiket.setText(null);
                comboStudio.setSelectedItem("Studio A");
                this.tampilTabel();
            } catch (SQLException ex) {
                Logger.getLogger(tambahDaftarTayang.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btnTambahActionPerformed

    private void btnBatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBatalActionPerformed
        txtId.setText(null); //untuk mengosongkan txt jika data sudah disimpan
        txtNamaFilm.setText(null);
        comboHari.setSelectedItem("Senin");
        comboJamTayang.setSelectedItem("09:00 - 12:00");
        txtHargaTiket.setText(null);
        comboStudio.setSelectedItem("Studio A");
    }//GEN-LAST:event_btnBatalActionPerformed

    private void btnUbahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUbahActionPerformed

        try {
            //setiap tipe data set yg bertipe int harus menggunakan integerparseint, integervalue untk mengambil data yg bertipe DATE
            daf.setNamaFilm(txtNamaFilm.getText());
            daf.setHari(comboHari.getSelectedItem().toString()); //selecteditem yg bertipe data Object  ditambahkan tipe data apasaja makan menjadi tipe data tsb
            daf.setJamTayang(comboJamTayang.getSelectedItem().toString());
            daf.setHargaTiket(Integer.parseInt(txtHargaTiket.getText()));
            daf.setStudio(comboStudio.getSelectedItem().toString());
            daf.UbahDaftarTayang(Integer.parseInt(txtId.getText()));
            JOptionPane.showMessageDialog(this, "Data Berhasil Diubah");
            txtId.setText(null); //untuk mengosongkan txt jika data sudah disimpan
            txtNamaFilm.setText(null);
            comboHari.setSelectedItem("Senin");
            comboJamTayang.setSelectedItem("09:00 - 12:00");
            txtHargaTiket.setText(null);
            comboStudio.setSelectedItem("Studio A");
            this.tampilTabel();
        } catch (SQLException ex) {
            Logger.getLogger(tambahDaftarTayang.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btnUbahActionPerformed

    private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed
        try {
            daf.deleteDaftarTayang(Integer.valueOf(txtId.getText()));
            JOptionPane.showMessageDialog(this, "Data Berhasil Dihapus");
            txtId.setText(null); //untuk mengosongkan txt jika data sudah disimpan
            txtNamaFilm.setText(null);
            comboHari.setSelectedItem("Senin");
            comboJamTayang.setSelectedItem("09:00 - 12:00");
            txtHargaTiket.setText(null);
            comboStudio.setSelectedItem("Studio A");
            this.tampilTabel();
        } catch (SQLException ex) {
            Logger.getLogger(tambahDaftarTayang.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnHapusActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                tambahDaftarTayang dialog = null;
                try {
                    dialog = new tambahDaftarTayang(new java.awt.Frame(), true);
                } catch (SQLException ex) {
                    Logger.getLogger(tambahDaftarTayang.class.getName()).log(Level.SEVERE, null, ex);
                }
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBatal;
    private javax.swing.JButton btnHapus;
    private javax.swing.JButton btnTambah;
    private javax.swing.JButton btnUbah;
    private javax.swing.JComboBox comboHari;
    private javax.swing.JComboBox comboJamTayang;
    private javax.swing.JComboBox comboStudio;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabelDaftarFilm;
    private javax.swing.JTextField txtHargaTiket;
    private javax.swing.JTextField txtId;
    private javax.swing.JTextField txtNamaFilm;
    // End of variables declaration//GEN-END:variables
}
